# @file    : flower_lang_test
# @time    : 2025/3/22
# @author  : yongpeng.yao
# @desc    :
import os

from dotenv import load_dotenv

load_dotenv()

from langchain.prompts import PromptTemplate

prompt = PromptTemplate.from_template("{flower}的花语是？")

from langchain_openai import ChatOpenAI

model = ChatOpenAI(
    model='deepseek-r1',
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)

from langchain.schema.output_parser import StrOutputParser

output_parser = StrOutputParser()

# 构建链
chain = prompt | model | output_parser

result = chain.invoke({"flower": "丁香"})
print(result)
